/****************************************************************************
*                                                                           *
* floor.h 																	*	
*                                                                           *
* ALaRI 2008												                *
*                                                                           *
****************************************************************************/

#pragma once

#if !defined(__FLOOR_H)
#define __FLOOR_H

/****************************************************************************
* Includes										                            *
****************************************************************************/
#include "../draw/drawmanager.h"
#include "../../common/defs.h"

#include <QWidget>
#include <QMouseEvent>
#include <QPaintEvent>
#include <QList>
#include <QPoint>

/****************************************************************************
* Forward declarations			 											*
****************************************************************************/
class QColor;
class QImage;
class CMaterial;

/****************************************************************************
* CFloorPlan - 					 											*
****************************************************************************/
class CFloorWidget : public QWidget
{
	Q_OBJECT
public: 
	/****************************************************************************
	* Public workers															*
	****************************************************************************/
	CFloorWidget(int nWidth = 400, int nHeight = 200);

	// constructs QImage object from current floor plan
	QImage convertToImage() const;
	// set color of the floor 
	void setAirColor(const QRgb& rgbColor);
	// set size of the floor 
	void resize(int nWidth, int nHeight);
	// gives width of the floor plan
	inline const int& getWidthR(void) const { return m_nWidth; }  
	// gives height of the floor plan
	inline const int& getHeightR(void) const { return m_nHeight; }  
	// gives width of the floor plan
	inline int getWidth(void) const { return m_nWidth; }  
	// gives height of the floor plan
	inline int getHeight(void) const { return m_nHeight; }  
	// sets height of the floor plan
	inline bool isValid(void)
	{ 
		if (m_nHeight < 1 || m_nHeight > 10000 || m_nWidth < 1 || m_nWidth > 10000)
			return false;
		return true;
	}
	// checks if the floor plan has changed 
	inline bool hasChanged(void) { return m_pDrawManager->hasImageChanged(); }
	// checks id point is inside the floor plan	
	bool isPointInside(const QPoint &rPoint);

	inline void setElaborated(bool bElaborated) { m_pDrawManager->setImageChanged(!bElaborated);}

	QSize sizeHint(void) const;

public slots :
	void setPenWidth(int nWidth);
	void setPenColor(const QRgb& rgbColor);
	void drawDemo();
	void drawWall();
	void drawRoom();
	void drawRoundRoom();
	void drawSpecial(const QPoint& qPointFrom, const QPoint& qPointTo, int nType);
	void setIdle();
	void putSensor();
	void deleteCurrentShape();

private slots:
	void addOrRemoveSensor(CSensorPoint*, bool);

protected:
	/****************************************************************************
	* Protected workers															*
	****************************************************************************/
	void mousePressEvent(QMouseEvent *pMouseEvent);
	void mouseMoveEvent(QMouseEvent *pMouseEvent);
	void mouseReleaseEvent(QMouseEvent *pMouseEvent);
	void paintEvent(QPaintEvent * pEvent);
	/****************************************************************************
	* Protected data															*
	****************************************************************************/
	CDrawManager						*m_pDrawManager;

private:
	int									m_nWidth;
	int									m_nHeight;

};

#endif /* __FLOOR_H */
/****************************************************************************
* End of file																*
****************************************************************************/

